package com.letv.whatslive.model.redis.chat.protocol;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

/**
 * 礼物消息，转json后放到ChatEnvent的Content中
 * Created by wangjian7 on 2016/5/17.
 */
public class Gift {

    //版本号
    private int version = 240;
    //文案
    private String title;
    //礼物ID
    private String id;
    //礼物数量
    private int count;
    //是否连击，0为否，1为是
    private int combo;
    //单价
    private double price;

    private Gift() {

    }

    public Gift(String json) {
        JSONObject jsonObject = JSON.parseObject(json);
        this.title = jsonObject.getString("title");
        this.id = jsonObject.getString("id");
        this.count = jsonObject.getInteger("count");
        this.combo = jsonObject.getInteger("combo");
        this.price = jsonObject.getDouble("price");
        this.version = jsonObject.getInteger("version");
    }

    public static Gift createGift(String id, String title, int count, int combo, double price) {
        Gift gift = new Gift();
        gift.setTitle(title);
        gift.setId(id);
        gift.setCount(count);
        gift.setCombo(combo);
        gift.setPrice(price);
        return gift;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public int getCombo() {
        return combo;
    }

    public void setCombo(int combo) {
        this.combo = combo;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }
}
